import {Map} from 'immutable'

import {CLASSIFY_SUB_DATA,CLASSIFY_GET_DATA} from '../actionType'

let data = Map({
    classifyData:[]
})


export let classifyReducer = (state=data,action)=>{
    switch(action.type){
        case CLASSIFY_SUB_DATA:
            return state.set("classifyData",action.payload)
        case CLASSIFY_GET_DATA:
            let result
            state.get("classifyData").forEach((v,i)=>{
                if(v.id === action.payload){
                    result =  v
                }
            })
            return result
        default:
            return state
    }
}